using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace CXDB
{
    /// <summary>
    /// Controller class for CX_Staff_Safty
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class CxStaffSaftyController
    {
        // Preload our schema..
        CxStaffSafty thisSchemaLoad = new CxStaffSafty();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public CxStaffSaftyCollection FetchAll()
        {
            CxStaffSaftyCollection coll = new CxStaffSaftyCollection();
            Query qry = new Query(CxStaffSafty.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxStaffSaftyCollection FetchByID(object Id)
        {
            CxStaffSaftyCollection coll = new CxStaffSaftyCollection().Where("ID", Id).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxStaffSaftyCollection FetchByQuery(Query qry)
        {
            CxStaffSaftyCollection coll = new CxStaffSaftyCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (CxStaffSafty.Delete(Id) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (CxStaffSafty.Destroy(Id) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(int? UserID,int? DeptID,DateTime? AccidentTime,string AccidentDuty,string AccidentReason,int? SaftyMasterID,DateTime? SaftyMasterTime,int? SaftyMasterStatus,string SaftyMasterRemark,int? DeptMasterId,string DeptMasterRemark,int? DeptMasterStatus,DateTime? DeptMasterTime,int? BossUserID,DateTime? BossTime,string BossRemark,int? BossStatus,int? EnteringUserID,DateTime? InTime,int? Status,Guid? Guid)
	    {
		    CxStaffSafty item = new CxStaffSafty();
		    
            item.UserID = UserID;
            
            item.DeptID = DeptID;
            
            item.AccidentTime = AccidentTime;
            
            item.AccidentDuty = AccidentDuty;
            
            item.AccidentReason = AccidentReason;
            
            item.SaftyMasterID = SaftyMasterID;
            
            item.SaftyMasterTime = SaftyMasterTime;
            
            item.SaftyMasterStatus = SaftyMasterStatus;
            
            item.SaftyMasterRemark = SaftyMasterRemark;
            
            item.DeptMasterId = DeptMasterId;
            
            item.DeptMasterRemark = DeptMasterRemark;
            
            item.DeptMasterStatus = DeptMasterStatus;
            
            item.DeptMasterTime = DeptMasterTime;
            
            item.BossUserID = BossUserID;
            
            item.BossTime = BossTime;
            
            item.BossRemark = BossRemark;
            
            item.BossStatus = BossStatus;
            
            item.EnteringUserID = EnteringUserID;
            
            item.InTime = InTime;
            
            item.Status = Status;
            
            item.Guid = Guid;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int Id,int? UserID,int? DeptID,DateTime? AccidentTime,string AccidentDuty,string AccidentReason,int? SaftyMasterID,DateTime? SaftyMasterTime,int? SaftyMasterStatus,string SaftyMasterRemark,int? DeptMasterId,string DeptMasterRemark,int? DeptMasterStatus,DateTime? DeptMasterTime,int? BossUserID,DateTime? BossTime,string BossRemark,int? BossStatus,int? EnteringUserID,DateTime? InTime,int? Status,Guid? Guid)
	    {
		    CxStaffSafty item = new CxStaffSafty();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.Id = Id;
				
			item.UserID = UserID;
				
			item.DeptID = DeptID;
				
			item.AccidentTime = AccidentTime;
				
			item.AccidentDuty = AccidentDuty;
				
			item.AccidentReason = AccidentReason;
				
			item.SaftyMasterID = SaftyMasterID;
				
			item.SaftyMasterTime = SaftyMasterTime;
				
			item.SaftyMasterStatus = SaftyMasterStatus;
				
			item.SaftyMasterRemark = SaftyMasterRemark;
				
			item.DeptMasterId = DeptMasterId;
				
			item.DeptMasterRemark = DeptMasterRemark;
				
			item.DeptMasterStatus = DeptMasterStatus;
				
			item.DeptMasterTime = DeptMasterTime;
				
			item.BossUserID = BossUserID;
				
			item.BossTime = BossTime;
				
			item.BossRemark = BossRemark;
				
			item.BossStatus = BossStatus;
				
			item.EnteringUserID = EnteringUserID;
				
			item.InTime = InTime;
				
			item.Status = Status;
				
			item.Guid = Guid;
				
	        item.Save(UserName);
	    }
    }
}
